package com.gdkm.servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.gdkm.dao.BlogDao;
import com.gdkm.daomain.Blog;

public class BlogClientServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=utf8");
		request.setCharacterEncoding("utf8");
		BlogDao blogDao = new BlogDao();
		String op = request.getParameter("op");
		if(op!=null && op.equals("listBlog")){
			try {
				List<Blog> listImgBlog=blogDao.findAllImgBlog();
				List<Blog> listNotImgBlog=blogDao.findAllNotImgBlog();
				request.setAttribute("listImgBlog", listImgBlog);
				request.setAttribute("listNotImgBlog", listNotImgBlog);
				request.getRequestDispatcher("/client/index.jsp").forward(request, response);
			} catch (SQLException e) {
				e.printStackTrace();
			}
			
		}
		else if(op!=null && op.equals("list")){
			
		}
	}

}
